Arduino Adventures: Escape From Gemini Station by James Floyd Kelly & Harold Timmis
Author:James Floyd Kelly & Harold Timmis [Kelly, James Floyd & Timmis, Harold]
Language: eng
Format: epub
Tags: Computers, General, Hardware, Technology & Engineering, Robotics
ISBN: 9781430246053
Publisher: Apress
Published: 2013-01-30T05:00:00+00:00
The Challenge 4 Sketch
Let’s start with a breakdown of what we need to do in this sketch. By making a list we can be certain we don’t miss anything, and it’ll help when we begin to explore the different sections of the sketch. Here’s what has to happen in the sketch:
We have to determine what variables are needed to communicate with all of the different IO (inputs and outputs).
We’ll use the setup structure to initialize the outputs, and use a few of the Arduino’s pull-up resistors.
In the loop structure, we’ll read in the state of the push buttons.
We also need to read the state of the analog input (potentiometer).
We have to scale the potentiometer values to fall between 0 and 256. The potentiometer will give a value between 0 and 1023, but we’ll divide by 4 to reduce that range to a more easily usable one. A smaller analog range means you will have the full range of the potentiometer rather than ¼ of the potentiometers range.
Next, we have to set up a conditional statement to compare the states of each of the push buttons to ON or OFF (0 or 1). Remember, because we chose to use the Arduino’s internal pull-up resistors (we did this in Challenge 2) and because of the way we designed the circuit, the states for ON and OFF are backward; that is, 1 represents OFF and 0 represents ON. Sometimes design choices will cause you to code sketches in different ways.
Finally, we need a state that controls the condition when neither push buttons is pressed. We don’t need to worry about both buttons being pressed as the motor will spin clockwise in this case due to the order of the If-Else statement.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8302)
Test-Driven Development with Java by Alan Mellor(6735)
Data Augmentation with Python by Duc Haba(6649)
Principles of Data Fabric by Sonia Mezzetta(6401)
Learn Blender Simulations the Right Way by Stephen Pearson(6299)
Microservices with Spring Boot 3 and Spring Cloud by Magnus Larsson(6171)
Hadoop in Practice by Alex Holmes(5959)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5807)
RPA Solution Architect's Handbook by Sachin Sahgal(5567)
Big Data Analysis with Python by Ivan Marin(5369)
The Infinite Retina by Robert Scoble Irena Cronin(5256)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(5150)
Pretrain Vision and Large Language Models in Python by Emily Webber(4333)
Infrastructure as Code for Beginners by Russ McKendrick(4095)
Functional Programming in JavaScript by Mantyla Dan(4038)
The Age of Surveillance Capitalism by Shoshana Zuboff(3956)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3808)
Embracing Microservices Design by Ovais Mehboob Ahmed Khan Nabil Siddiqui and Timothy Oleson(3612)
Applied Machine Learning for Healthcare and Life Sciences Using AWS by Ujjwal Ratan(3583)
